<?php

class GameController extends Phalcon\Mvc\Controller
{
	/**
	 * Game
	 *
	 * @string
	 */
	public $game = null;

	/**
	 * Initialize the player interaction with a game
	 *
	 * @param int Game id number
	 * @return Page
	 */
	public function initialize() {
		if (!$this->session->has("player")) {
			$this->response->redirect("/", true);
		}
		$this->view->setVar("player", $this->session->get("player"));

		// Validate if the game exists
		$this->game = Games::findFirst(array("id"=>$this->request->get("game", "int")));
		if (!$this->game) {
			$this->response->redirect("/games/list", true);
		}

		// Validate if the player has access
		$this->game = Games::findFirst(array("id"=>$this->request->get("game", "int")));
	}

	/**
	 * This is called when a player plays a card
	 *
	 * @param int Game id number
	 * @return Page
	 */
	public function indexAction() {

	}

	/**
	 * This is called when a player plays a card
	 *
	 * @param int Game id number
	 * @return json of game status after card played
	 */
	public function statusAction() {
	}

	/**
	 * This is called when a player plays a card
	 *
	 * @param int Game id number
	 * @param string (get) Card played
	 * @return json of game status after card played
	 */
	public function playAction() {
	}
}
